<template>
	<main class="cart_box background_f0">
		<div class="line_height40 overflow_hidden padding_lf10_rg10 border_bot_dcdcdc">

			<div class="fr">
				<span>需支付：<strong class="color_main_red">{{totalPrice}}元</strong></span>
			</div>
		</div>
		<div class="line_height40 overflow_hidden padding_lf10_rg10 border_bot_dcdcdc background_fff">
			<div class="fl">
				<img src="../assets/images/weixinpay_icon.png" /><span>微信支付</span>
			</div>
			<!--<div class="fr">
				<img src="../assets/images/select_btn_icon.png" class="vertical_align_mid"/>
			</div>-->
		</div>
		<!--<div class="line_height40 overflow_hidden padding_lf10_rg10 border_bot_dcdcdc background_fff">
			
			<div class="fl">
				<span>支付宝支付</span>
			</div>
			<div class="fr">
				<img src="../assets/images/select_btn_icon.png" class="vertical_align_mid" />
			</div>
		</div>-->
		<div @click="WXOrderPay()" class="btn_bot bottom66">
			支付
		</div>
	</main>
</template>
<script>
	import { Switch } from 'mint-ui';
	import { Toast } from 'mint-ui';
	export default {
		created() {
			let _this = this
			_this.OrderId = _this.$route.query.OrderId
			_this.totalPrice = _this.$route.query.totalPrice

			console.log('orderid', _this.OrderId)
		},
		data() {
			return {
				OrderId: '',
				totalPrice: 0
			}
		},
		mounted() {

		},
		methods: {
			WXOrderPay() {
				let _this = this
				_this.$http.post('/client/OrderPays', {
					OrderId: _this.OrderId,
					PayType: 2
				}, localStorage.Authorization, res => {
					console.log('支付res', res)
					if(res.code === 200) {
						
						WeixinJSBridge.invoke(
							'getBrandWCPayRequest', JSON.stringify(res.data),
							function(res) {
								console.log('resssss', res)
								if(res.err_msg == "get_brand_wcpay_request:ok") {
									console.log('re222', res)
									
									// 使用以上方式判断前端返回,微信团队郑重提示：
									// res.err_msg将在用户支付成功后返回
									// ok，但并不保证它绝对可靠。
								}
							}
						);
						
					} else {
						Toast(res.error)
					}
				})
			},
		},
		watch: {

		}
	}
</script>
<style scoped="scoped">

</style>